﻿using Frogsoft.Permission.Consts;
using Microsoft.Extensions.DependencyInjection;

namespace Frogsoft.Permission
{
    public static class PermissionServiceExtensions
    {
        public static void AddPolicys(this IServiceCollection services)
        {
            services.AddAuthorization(options =>
            {
                foreach (var item in StaticPermissions.PermissionList)
                {
                    options.AddPolicy(item.PermissionName, policy => policy.RequireClaim(item.PermissionName));
                }
            });
        }
    }
}
